package com.dream.controller;

import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.dream.pojo.TimeAxis;
import com.dream.service.able.All_Service_able;

/*
 * 时间轴页面请求控制层
 */
@RequestMapping("/time")
@Controller
public class TimeController {
	
	/*
	 * 时间轴业务处理对象
	 */
	@Resource(name="Time_axis_Serviceimpl")
	private All_Service_able<TimeAxis> time_axis_service;

	/*
	 * 跳转到编辑笔记页面的请求
	 */
	@RequestMapping("write")
	public String getwritetime(){
		return "writetime";
	}
	
	/*
	 * 保存笔记的请求
	 */
	@RequestMapping(value="insert",produces = "text/plain;charset=utf-8")
	public String insertTime(String context){
		time_axis_service.insert(context);
		return "forward:read";
	}
	
	/*
	 * 查看笔记页面的请求
	 */
	@RequestMapping("read")
	public String getTimeline(Model model){
		model.addAttribute("listTime_axis",time_axis_service.list());
		return "timeline";
	}
	
	
	/*
	 * 测试，json数据
	 */
	@ResponseBody
	@RequestMapping("getTemp")
	public Object getTemp(){
		return time_axis_service.list();
	}
	
}
